﻿using Core.RabbitMQ.Consumer;
using Core.WebApi.Consume.Dto;
using Newtonsoft.Json;

namespace Core.WebApi.Consume
{
    public class OrderConsumer : IConsumer<OrderMessage>, IConsumer<RegisterMessage>
    {
        private readonly ILogger<OrderConsumer> _logger;

        public OrderConsumer(ILogger<OrderConsumer> logger)
        {
            _logger = logger;
        }
        public Task ReceiveMessageAsync(string messageId, OrderMessage message, CancellationToken cancellationToken)
        {
            _logger.LogInformation($"消费消息：ID:{messageId},Body：" + JsonConvert.SerializeObject(message));
            return Task.CompletedTask;
        }

        public Task ReceiveMessageAsync(string messageId, RegisterMessage message, CancellationToken cancellationToken)
        {
            _logger.LogInformation($"消费消息：ID:{messageId},Body：" + JsonConvert.SerializeObject(message));
            return Task.CompletedTask;
        }
    }
}
